import server from './http.js' //导入axios
// 登录模块
const getLogin = (msg) => {
    let data = server.post('/login', msg)
    return data
}
//左侧导航
const menusList = () => {
    let data = server.get('/menus')
    return data
}

// 用户模块
//用户列表
const userlist = (params) => {
    // let data =  server.get('/users', {params:params})
    let data = server.get('/users', { params })
    return data
}

const delUser = (id) => {
    let data = server.delete("users/" + id)
    return data
}

const editUsers = (id, params) => {
    let data = server.put("users/" + id, params)
    return data
}

const changeStatus = (id, type) => {
    let data = server.put(`users/${id}/state/${type}`)
    return data
}


const addUsers = (params) => {
    let data = server.post("users", params)
    return data
}

const getRoles = () => {
    let data = server.get("roles")
    return data
}

const addRoles = (params) => {
    let data = server.post("roles", params)
    return data
}

const delRoles = (id) => {
    let data = server.delete("roles/" + id)
    return data
}

const editRoles = (id, params) => {
    let data = server.put("roles/" + id, params)
    return data
}

const Rights = (type) => {
    let data = server.get("rights/" + type)
    return data
}

const Goods = (params) => {
    let data = server.get(`goods`, { params })
    return data
}

const delGoods = (id) => {
    let data = server.delete('goods/'+id)
    return data
}

export {
    getLogin, Rights,delGoods, Goods, addRoles, editRoles, delRoles, menusList, userlist, delUser, editUsers, changeStatus, addUsers, getRoles
}


//接口要命名规范,-获取数据getLogin,设置提交数据 setLogin,
//删除数据 delLogin,列表数据 loginList等